<?php
header('Content-type:text/html;charset=utf-8');//设置编码格式
session_start();
include_once 'dbconfig.php';
include_once 'common.php';


if (isset($_SESSION['loginUserName'])) {
    $name = $_SESSION['loginUserName'];
} else {
    $msg = ['msg' => '请先登录！', 'status' => 0];
    responseEvent($msg);
}

if ($_GET) {
    if (isset($_GET['getType']) && $_GET['getType'] == 'getShopCart') {
        $str = 'select s.color as scolor,s.num,s.id as sid,p.* from shop_cart as s JOIN product as p on s.pro_id = p.id where s.username = "' . $name . '" and s.status !=-1';
        judge($str);
    }
}
if ($_POST) {
    if (isset($_POST['postType']) && $_POST['postType'] == 'deleteItem') {
        $id = $_POST['id'];
        $str = 'update shop_cart set status = -1 where id=' . $id;
        if ($link->query($str) === true) {
            $msg = ['msg' => '删除成功！', 'status' => 1];
        } else {
            $msg = ['msg' => '删除失败！', 'status' => 0];
        }
        responseEvent($msg);
    }
}